import { ModalForm, ProFormText } from '@ant-design/pro-form';
import { FC } from 'react';

type CreateFormProps = {
  createModalVisible: boolean;
  handleCreateModalVisible: any;
  handleCreate: (values: ADMIN.Role) => void;
};

const CreateForm: FC<CreateFormProps> = (props) => {
  const { handleCreate, createModalVisible, handleCreateModalVisible } = props;

  return (
    <ModalForm<ADMIN.Role>
      title="新建角色"
      width="500px"
      visible={createModalVisible}
      onVisibleChange={handleCreateModalVisible}
      onFinish={async (value) => {
        handleCreate(value);
      }}
    >
      <ProFormText
        name="name"
        label="名称"
        rules={[{ required: true, message: '请输入名称' }]}
        placeholder="请输入名称"
      />
      <ProFormText
        name="remark"
        label="标识"
        rules={[{ required: true, message: '请输入标识' }]}
        placeholder="请输入标识"
      />
    </ModalForm>
  );
};

export default CreateForm;
